package cn.zzp.system.service.impl;

import cn.zzp.basic.service.impl.BaseServiceImpl;
import cn.zzp.system.domain.DictionaryType;
import cn.zzp.system.mapper.DictionaryDetailMapper;
import cn.zzp.system.mapper.DictionaryTypeMapper;
import cn.zzp.system.service.DictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName EmployeeServiceImpl
 * @Description
 * @Author 祝志鹏
 * @Date 2022/7/14 14:16
 */
@Service
//@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DictionaryTypeServiceImpl extends BaseServiceImpl<DictionaryType> implements DictionaryTypeService {
    @Autowired
    private DictionaryDetailMapper dictionaryDetailMapper;
    @Autowired
    private DictionaryTypeMapper dictionaryTypeMapper;

    @Transactional
    @Override
    public void delete(Long id){
        // 删除前先删除关联数据
        dictionaryDetailMapper.deleteByTypeId(id);
        dictionaryTypeMapper.delete(id);
    }

    @Transactional
    @Override
    public void patchDel(List<Long> ids){
        // 删除关联数据
        dictionaryDetailMapper.patchDelByTypeIds(ids);
        dictionaryTypeMapper.patchDel(ids);
    }
}
